package com.thesis.client;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.thesis.object.ListBill;

public class BillAdapter extends BaseAdapter {
	private final Context context;
	private final ListBill listBill;
	

	public BillAdapter(Context context, ListBill listBill) {
	
		this.context = context;
		this. listBill =  listBill;

	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView;
		if (convertView == null) {
			rowView = new View(context);
			rowView = inflater.inflate(R.layout.item_bill, parent, false);
		} else {
			rowView = (View) convertView;
		}
		
		TextView tv_date = (TextView) rowView.findViewById(R.id.ib_tv_date);
		TextView tv_table = (TextView) rowView.findViewById(R.id.ib_tv_table);
		TextView tv_cost = (TextView) rowView.findViewById(R.id.ib_tv_cost);
		
		tv_date.setText(""+listBill.getListBill().get(position).getEndTime());
		tv_table.setText(""+listBill.getListBill().get(position).getTableId());
		tv_cost.setText(""+listBill.getListBill().get(position).getTotalCost());
		

		return rowView;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listBill.getListBill().size();
	}

	

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}
}